package com.cn.trip.service;


import com.cn.trip.DbDao.CartDao;
import com.cn.trip.DbDao.GoodsDao;

public class AddToCartService {
	
	public boolean addtToCart(int user_id,int goods_id) {
		GoodsDao goodsDao=new GoodsDao();
		CartDao cartDao=new CartDao();
		if(goodsDao.getGoodsNum(goods_id)>0) {
			System.out.println(cartDao.exist(user_id, goods_id));
			if(cartDao.exist(user_id, goods_id)) {
				cartDao.updateCart(user_id, goods_id);
				return true;
			}else {
				cartDao.addToCart(user_id, goods_id);
				return true;
			}
			
		}
		return false;
		
	}
}
